package com.ruoyi.web.controller.system;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.BEMbpz;
import com.ruoyi.system.service.IBEMbpzService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 完整性检测Controller
 *
 * @author ruoyi
 * @date 2023-09-22
 */
@RestController
@RequestMapping("/system/mbpz")
public class BEMbpzController extends BaseController
{
    @Autowired
    private IBEMbpzService bEMbpzService;

    /**
     * 查询完整性检测列表
     */
    //@PreAuthorize("@ss.hasPermi('system:mbpz:list')")
    @GetMapping("/list")
    public TableDataInfo list(BEMbpz bEMbpz)
    {
        startPage();
        List<BEMbpz> list = bEMbpzService.selectBEMbpzList(bEMbpz);
        return getDataTable(list);
    }

    /**
     * 导出完整性检测列表
     */
    //@PreAuthorize("@ss.hasPermi('system:mbpz:export')")
    @Log(title = "完整性检测", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BEMbpz bEMbpz)
    {
        List<BEMbpz> list = bEMbpzService.selectBEMbpzList(bEMbpz);
        ExcelUtil<BEMbpz> util = new ExcelUtil<BEMbpz>(BEMbpz.class);
        util.exportExcel(response, list, "完整性检测数据");
    }

    /**
     * 获取完整性检测详细信息
     */
    //@PreAuthorize("@ss.hasPermi('system:mbpz:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(bEMbpzService.selectBEMbpzById(id));
    }

    /**
     * 新增完整性检测
     */
    //@PreAuthorize("@ss.hasPermi('system:mbpz:add')")
    @Log(title = "完整性检测", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BEMbpz bEMbpz)
    {
        return toAjax(bEMbpzService.insertBEMbpz(bEMbpz));
    }

    /**
     * 修改完整性检测
     */
    //@PreAuthorize("@ss.hasPermi('system:mbpz:edit')")
    @Log(title = "完整性检测", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BEMbpz bEMbpz)
    {
        return toAjax(bEMbpzService.updateBEMbpz(bEMbpz));
    }

    /**
     * 删除完整性检测
     */
    //@PreAuthorize("@ss.hasPermi('system:mbpz:remove')")
    @Log(title = "完整性检测", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(bEMbpzService.deleteBEMbpzByIds(ids));
    }
}
